import request from '@/config/axios'

// 功能室预约 VO
export interface RoomReserveVO {
  id: number // 编号
  schoolCode: string // 园区
  roomId: number // 功能室ID
  roomType: undefined //类型
  classId: string // 班级
  userName: string // 预约人
  startTime: Date // 会议开始时间
  endTime: Date // 会议结束时间
  fileUrls: string // 会议纪要文件
  sort: number // 排序
  status: number // 状态
}

// 功能室预约 API
export const RoomReserveApi = {
  // 查询功能室预约分页
  getRoomReservePage: async (params: any) => {
    return await request.get({ url: `/school/room-reserve/page`, params })
  },

  // 查询功能室预约详情
  getRoomReserve: async (id: number) => {
    return await request.get({ url: `/school/room-reserve/get?id=` + id })
  },

  // 新增功能室预约
  createRoomReserve: async (data: RoomReserveVO) => {
    return await request.post({ url: `/school/room-reserve/create`, data })
  },

  // 修改功能室预约
  updateRoomReserve: async (data: RoomReserveVO) => {
    return await request.put({ url: `/school/room-reserve/update`, data })
  },

  // 删除功能室预约
  deleteRoomReserve: async (id: number) => {
    return await request.delete({ url: `/school/room-reserve/delete?id=` + id })
  },

  // 取消预约
  cancelRoomReserve: async (id: number) => {
    return await request.put({ url: `/school/room-reserve/cancel?id=` + id })
  },

  // 导出功能室预约 Excel
  exportRoomReserve: async (params) => {
    return await request.download({ url: `/school/room-reserve/export-excel`, params })
  },

  // 根据月份查询预约-查询每天是否有预约
  getMeetingReserveByMonth: async (month: string, roomType: string) => {
    return await request.get({
      url: `/school/room-reserve/get-by-month?month=${month}&roomType=${roomType}`
    })
  },

  // 根据日期查询预约列表
  getMeetingReserveByDay: async (params) => {
    return await request.get({ url: `/school/room-reserve/get-by-day`, params })
  },

  // 查询功能室维护信息
  async getRoomMaintain(id) {
    return await request.get({ url: `/school/room-reserve/query-maintain?id=${id}` })
  },

  // 修改功能室维护信息
  async updateRoomMaintain(data) {
    return await request.put({ url: `/school/room-reserve/update-maintain`, data })
  }
}
